/*
 * @version: 1.0
 * @Author: zhl
 * @Date: 2021-09-01 09:11:36
 * @LastEditors: zhl
 * @LastEditTime: 2021-09-30 17:08:29
 * @Description: 文件实现描述
 */

#include "SerialInterface.h"



SerialInterface::SerialInterface(std::string addr, SERIAL_PARAMS param){
	c_addr = addr;
	c_serial_params = param;
}

SerialInterface::SerialInterface(){

}

SerialInterface::~SerialInterface(){

}

void SerialInterface::set_addr(std::string addr){
	c_addr = addr;
}

void SerialInterface::set_baud_rate(int baud_rate){
	c_serial_params.baudRate = baud_rate;
}

void SerialInterface::set_parity_check(std::string parity){
	c_serial_params.parity = parity;
}

void SerialInterface::set_stop_bit(uint8_t stop_bit){
	c_serial_params.stopBits = stop_bit;
}

void SerialInterface::set_data_bits(uint8_t data_bits){
	c_serial_params.byteSize = data_bits;
}

void SerialInterface::set_params(SERIAL_PARAMS param){
	c_serial_params = param;
}

SERIAL_PARAMS &SerialInterface::get_serial_params(){
	return c_serial_params;
}

std::string SerialInterface::get_addr(){
	return c_addr;
}

int SerialInterface::send_request(uint8_t *buf, int buf_len, int req_id, int priority){

	if((NULL == buf) || ( 1 > buf_len)){
		return -1;
	}
	return 0;
}

int SerialInterface::get_request_msg(uint8_t *buf, int buf_len, int req_id, int priority, std::string &msg){

	return 0;
}